package com.twu.biblioteca.Options;

import com.twu.biblioteca.DataBase.ListOfItems;

import java.util.ArrayList;

public class Manager {
    private ArrayList<Option> options = new ArrayList<Option>();

    private final ListOfItems listOfItems;
    public Manager() {
        listOfItems = new ListOfItems();
        options.add(new CheckOutOption());
        options.add(new ReturnBookOption());
        options.add(new ReturnMovieOption());
        options.add(new ListBooksOption());
        options.add(new ListMoviesOption());
        options.add(new ListOptionsOption());
    }

    public void handle(String optionName) {
        for(Option option : options){
            if (option.getName().equals(optionName)){
                try {
                    option.execute(listOfItems);
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        System.out.println("Select a valid option!");
        return;
    }
}
